/////////////////////////////////////////////////
// Book of Angels
// (c) Copyright 2013 Edward Principe
// All Rights Reserved
////////////////////////////////////////////////
#ifndef SYNTAXEX_H
#define SYNTAXEX_H

#include <Windows.h>
#include <tchar.h>
#include "stdex.h"

//////////////////////////////////////////////////
// Error codes
//////////////////////////////////////////////
enum SyntaxErr
{
	SE_DUP_DEF,
	SE_SYNTAX,
	SE_BAD_STRING,
	SE_NONE=9999
};

///////////////////////////////////////////////
// SyntaxEx: Syntax error class
//////////////////////////////////////////////
class SyntaxEx : public StdEx
{
public: // Constructio
	SyntaxEx(SyntaxErr err = SE_NONE, unsigned long line = 0, unsigned long col = 0) : StdEx()
	{
		PutErr(err, line, col);
	}

	SyntaxEx(const SyntaxEx& rhs)
	{
		Copy(rhs);
	}

public: // Methods
	void PutErr(SyntaxErr err = SE_NONE, unsigned long line = 0, unsigned long col = 0); // Assigns an error to the class

public: // Accessor methods
	SyntaxErr GetErr() const {return _err;}
	unsigned long GetLine() const {return _line;}
	unsigned long GetCol() const {return _col;}

public: // Operators
	SyntaxEx& operator = (const SyntaxEx& rhs)
	{
		Copy(rhs);
		return *this;
	}


private: // Methods
	void Init(SyntaxErr err, unsigned long line, unsigned long col)
	{
		_err = err;
		_line = line;
		_col = col;
	}

	void Copy(const SyntaxEx& rhs)
	{
		if(this == &rhs)
			return;

		_err = rhs._err;
		_line = rhs._line;
		_col = rhs._col;

		StdEx::Copy(rhs);
	}

private: // Attribtes
	unsigned long _line;
	unsigned long _col;
	SyntaxErr _err;
};
#endif